Skip to content

Added GM:OnDuplicated(ent, entDupeTable), GMod PR#528

Open
Grocel wants to merge 1 commit into
wiremod:masterfrom
Grocel:minor-duplication-hook-addition
Open

Added GM:OnDuplicated(ent, entDupeTable), GMod PR#528
Grocel wants to merge 1 commit into
wiremod:masterfrom
Grocel:minor-duplication-hook-addition

Conversation

@Grocel

@Grocel Grocel commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

In adjacent to: Facepunch/garrysmod#2408

Works like ENTITY:OnDuplicated(ent, entDupeTable) but doesn't require adding/detouring ent.OnDuplicated on OnEntityCreated calls for addon-foreign entities.

This adds a easy way to add generic logic early to the duplication life cycle. It is called a way before duplicator.RegisterEntityModifier() added callers are being iterated. The new hook also reduces the risk of conflicts caused by detours of pre-existing ent.OnDuplicated code.

Test script:

if SERVER then
    hook.Add("OnDuplicated", "Test", function(ent, entTable)
        print(ent)
        PrintTable(entTable)
    end)
end

In adjacent to: Facepunch/garrysmod#2408

Works like `ENTITY:OnDuplicated(ent, entDupeTable)` but doesn't require adding/detouring `ent.OnDuplicated` on `OnEntityCreated` calls for addon-foreign entities.
@Grocel

Grocel commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

The linter results are not relevant to my changes, so I can't fix them.

Grocel added a commit to Grocel/sligwolf_addon_base that referenced this pull request Dec 14, 2025
Removes the need for the "OnEntityCreated" hack.

Requires these pull request to be merged:
- Facepunch/garrysmod#2408
- wiremod/advdupe2#528
@Astralcircle

Copy link
Copy Markdown
Contributor

I don't see any point in merging this until it's merged into GMOD. Because very few addons rely on the AdvDupe2 duplicator specifically

@Grocel

Grocel commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

I don't see any point in merging this until it's merged into GMOD. Because very few addons rely on the AdvDupe2 duplicator specifically

Yeah, that's alright. It might change depending on how Rubat wants to have it done for GMod anyways. Rubat actually responded to the PR for GMod and asked for additional feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants